/******************************************************************************
 *                       B O M B E R M A N  2 0 1 2
 * 
 * File Name: BombermanThread.java
 * 
 * COP 4331 Summer 2012 Project
 * 
 * Authors: Trevor Mancuso, Chris Chiarella, Zach Hoyler, Daniel Martin
 * 
 * 
 * Description: Thread that holds a new bomberman game.
 * 
 ******************************************************************************/
package bomberman;

/**
 *
 * @author Trevor
 */
public class BombermanThread implements Runnable{
    
    Menu menu = null;
    boolean host;
    String opAddress;
    boolean network=false;
    Bomberman game;
    int numPlayers;
    int ai_ID;
    
    //constructor for local play
    BombermanThread(Menu menu, int numPlayers, int ai_ID)
    {
        this.menu = menu;
        this.numPlayers = numPlayers;
        this.ai_ID = ai_ID;
    }
    //constructor for network play
    BombermanThread(Menu menu, Boolean host, String opAddress, Boolean network)
    {
        this.menu = menu;
        this.host = host;
        this.opAddress = opAddress;
        this.network = network;
    }
    
    public void run(){
        try{
            if(!network)
                game = new Bomberman(numPlayers,ai_ID);
            if(network)
                game = new Bomberman(opAddress,host);
            
        }catch(NullPointerException ex)
        {
            System.out.println("CLOSED");
            menu.setVisible(true);
        }
    }
    
}
